import {createSwitchNavigator, createAppContainer} from 'react-navigation';
import FetchDemoPage from '../page/FetchDemoPage'
// import { createBottomTabNavigator, createMaterialTopTabNavigator } from "react-navigation-tabs";
 import { createStackNavigator } from "react-navigation-stack";
import WelcomePage from '../page/WelcomePage';
import HomePage from '../page/HomePage';
import DataStoreDemoPage from '../page/DataStoreDemoPage'
import AsyncStorageDemoPage from '../page/AsyncStorageDemoPage'
import DetailPage from '../page/DetailPage';
import { connect } from 'react-redux';
import {createReactNavigationReduxMiddleware, createReduxContainer} from 'react-navigation-redux-helpers';
export const rootCom = 'Init';

const  InitNavigator = createStackNavigator({
   WelcomePage:{
       screen: WelcomePage,
       navigationOptions:{
           header:null,
       }
   }
});

const  MainNavigator = createStackNavigator({
    HomePage:{
        screen: HomePage,
        navigationOptions:{
            header:null,
        }
    },
    DetailPage:{
        screen: DetailPage,
        navigationOptions:{
            // header:null,
        }
    },
    FetchDemoPage: {
        screen: FetchDemoPage,
        navigationOptions: {
            // header:null,
        }
    },
    AsyncStorageDemoPage: {
        screen: AsyncStorageDemoPage,
        navigationOptions: {
            // header:null,
        }
    },
    DataStoreDemoPage:{
        screen: DataStoreDemoPage,
        navigationOptions:{
            // header:null,
        }
    },
});
export const RootNavigator =  createAppContainer(createSwitchNavigator({
    Init: InitNavigator,
    Main: MainNavigator,

}, {
    navigationOptions:{
        header:null,
    }
}));

export const middleware = createReactNavigationReduxMiddleware(
    state => state.nav,
    'root'
);
const AppWithNavigationState = createReduxContainer(RootNavigator, 'root');

const mapStateToProps = state=> ({
   state: state.nav,//v2
});

export default connect(mapStateToProps)(AppWithNavigationState);
